var t = getApp(), a = "plugin.store-alone-temp.frontend.videoShare.goods.getGoodsByKeyword", o = "plugin.store-alone-temp.frontend.videoShare.goods.getRecommendGoods";

Component({
    properties: {},
    data: {
        language: "",
        inputsData: "",
        show1: !1,
        goodList: [],
        chooseGoods: null,
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        loading: !1
    },
    lifetimes: {
        attached: function() {
            this.initData(), this.getRecommendGoods();
            var t = wx.getStorageSync("langIndex");
            this.setData({
                language: t.en
            });
        },
        moved: function() {},
        detached: function() {}
    },
    methods: {
        goBack: function() {
            this.triggerEvent("closeChooseGoods", {
                goods_id: this.data.chooseGoods
            });
        },
        initData: function() {
            this.setData({
                inputsData: "",
                show1: !1,
                goodList: [],
                chooseGoods: null
            }), this.data.inputs = "";
        },
        inpbtn: function(t) {
            var a = t.detail;
            this.data.inputs = a;
        },
        inpbtnclear: function() {
            this.setData({
                inputsData: ""
            }), this.data.inputs = "";
        },
        getData: function() {
            var o = this;
            o.data.isLoadMore = !0, o.data.page = 1, o.data.total_page = 0, o.data.loading = !1;
            var e = t.getNetAddresss(1 == t.globalData.store_alone_temp ? a : "plugin.video-share.frontend.goods.getGoodsByKeyword");
            t._getNetWork({
                url: e,
                data: {
                    keyword: this.data.inputs
                },
                success: function(t) {
                    var a = t.data;
                    1 == a.result ? o.setData({
                        goodList: a.data.list.data,
                        total_page: a.data.list.last_page
                    }) : wx.showToast({
                        title: a.msg,
                        icon: "none",
                        duration: 1500
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        },
        chooseGood: function(t) {
            var a = t.currentTarget.dataset.id;
            this.setData({
                chooseGoods: a
            }), this.gotoRelease();
        },
        gotoRelease: function() {
            console.log(t._isTextEmpty(this.data.chooseGoods)), t._isTextEmpty(this.data.chooseGoods) ? wx.showToast({
                title: "选择的商品为空",
                icon: "none",
                duration: 1500
            }) : this.triggerEvent("closeChooseGoods", {
                goods_id: this.data.chooseGoods
            });
        },
        getRecommendGoods: function() {
            var a = this, e = t.getNetAddresss(1 == t.globalData.store_alone_temp ? o : "plugin.video-share.frontend.goods.getRecommendGoods");
            t._getNetWork({
                url: e,
                data: {
                    page: 1
                },
                success: function(t) {
                    var o = t.data;
                    1 == o.result ? a.setData({
                        goodList: o.data.list.data,
                        total_page: o.data.list.last_page
                    }) : wx.showToast({
                        title: o.msg,
                        icon: "none",
                        duration: 1500
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        },
        getMoreData: function() {
            var e = this;
            console.log(this.data.inputs);
            var s = this.data.inputs ? 1 == t.globalData.store_alone_temp ? a : "plugin.video-share.frontend.goods.getGoodsByKeyword" : 1 == t.globalData.store_alone_temp ? o : "plugin.video-share.frontend.goods.getRecommendGoods", d = t.getNetAddresss(s), i = this.data.inputs ? {
                page: e.data.page + 1,
                keyword: this.data.inputs
            } : {
                page: e.data.page + 1
            };
            e.data.isLoadMore = !1, this.data.page >= this.data.total_page ? e.setData({
                loading: !0
            }) : (this.setData({
                page: this.data.page + 1
            }), console.log(this.data.page, i), t._getNetWork({
                url: d,
                data: i,
                success: function(t) {
                    var a = t.data;
                    if (1 == a.result) {
                        var o = a.data.list.data;
                        e.setData({
                            goodList: e.data.goodList.concat(o),
                            total_page: a.data.list.last_page
                        });
                    } else e.data.page = e.data.page - 1, e.data.loading = !0, e.data.isLoadMore = !1;
                },
                fail: function(t) {
                    console.log(t);
                }
            }));
        }
    }
});